#include"Cell.h"


Cell::Cell(const Cell &obj, bool copyScene): GameEntity(obj, copyScene)
{
    posX = obj.posX;
    posY = obj.posY;
    type = obj.type;
    setZValue(obj.zValue());
}


Cell& Cell::operator = (const Cell & obj)
{
    GameEntity::operator = (obj);
    posX = obj.posX;
    posY = obj.posY;
    type = obj.type;
    setZValue(obj.zValue());
    return (*this);
}


Cell::Cell(char Type, int X , int Y ): type(Type), posX(X), posY(Y)
{
    QString resourcePath;
    switch(type)
    {
    case 'W': resourcePath = ":/Gameitems/wall.png";
              break;
    case 'B': resourcePath = ":/Gameitems/bush.png";
              break;
    case 'E': resourcePath = ":/Gameitems/empty.png";
              break;
    default: resourcePath = ":/Gameitems/empty.png";
    }
    m_ptr_bitmap = new QPixmap(resourcePath);
}


Cell::~Cell()
{ }

void Cell::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0)
{
   int scale =25;
   this->setPos(posX*scale,posY*scale);
   painter->drawPixmap(0,0,scale,scale,*m_ptr_bitmap);
}

QPixmap* Cell::GetBitmap()
{
   return m_ptr_bitmap;
}

QRectF Cell::boundingRect() const
{
   return QRectF(QPointF(0, 0), m_ptr_bitmap->size());
}

QSizeF Cell::size() const
{
   return m_ptr_bitmap->size();
}

char Cell::GetType()
{
    return type;
}
